package com.example.zcapi

import android.text.TextUtils
import com.blankj.utilcode.util.SPUtils

object AppConfig {

    const val PREFERENCE_NAME_PRIVACY = "iscreen_Privacy"

    const val PREFERENCE_NAME = "iscreen"

    const val PREFERENCE_LIST = "iscreen_list"

    const val SCREENSAVER_LIST = "screensaver_list"

    const val PRIVACY = "privacy"

    const val DEVICEID = "DeviceId"

    const val ROMTYPE = "RomType"

    const val SCREENTYPE = "ScreenType"

    const val DEVICESTATUS = "DeviceId_STATUS"

    const val ORGANIZATION = "OrgId"

    const val PLANID = "PlanId"

    const val APPVERSION = "AppVersion"

    const val NETWORK = "NetWork"

    const val IPADRESS = "IPAdress"



//    const val POWEROFFYEAR = "PowerOff_Year"
//    const val POWEROFFMONTH = "PowerOff_Month"
//    const val POWEROFFDAY = "PowerOff_Day"
    const val POWEROFFHOUR = "PowerOff_Hour"
    const val POWEROFFMINUTE = "PowerOff_Minute"
    const val POWEROFFSTATUS = "PowerOff_Status"

    const val POWERONHOUR = "PowerOn_Hour"
    const val POWERONMINUTE = "PowerOn_Minute"
    const val POWERONOFFTYPE= "PowerOn_And_Off"

    const val MACADRESS = "MacAdress"

    const val ADVERTISELIST = "AdvertiseList"

    const val SCREENSAVER = "ScreenSaver"

    const val INTENTENV = "INTENTENV"

    const val CLIENTIDENTIFIER = "ClientIdentifier"

    const val Orientation = "Orientation"

    const val REBOOTTYPE = "RebootType"

    const val CacheVaildDay = "Cache_Vaild_Day"


    const val REBOOTSTATUS = "RebootStatus"

    /**
     * 是否同意协议
     *
     * @return
     */
    @JvmStatic
    fun isAgreePolicy(): Boolean {
        return !SPUtils.getInstance(PREFERENCE_NAME)
            .getBoolean("launchRequestPermission", true)
    }

    /**
     * 同意协议
     */
    @JvmStatic
    fun completeAgreePolicy() {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            "launchRequestPermission", false, true
        )
    }


    @JvmStatic
    fun getCacheVailidDay(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(CacheVaildDay)
    }

    @JvmStatic
    fun setCacheVailidDay(day: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            CacheVaildDay, day, true)
    }

    @JvmStatic
    fun getPrivacy(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME_PRIVACY).getInt(PRIVACY)
    }

    @JvmStatic
    fun setPrivacy(isPrivacy: Int) {
        SPUtils.getInstance(PREFERENCE_NAME_PRIVACY).put(
            PRIVACY, isPrivacy, true)
    }


    @JvmStatic
    fun getDeviceId(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            DEVICEID) ?: ""
    }

    @JvmStatic
    fun setDeviceId(deviceId: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            DEVICEID, deviceId, true)
    }

    @JvmStatic
    fun getRomType(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            ROMTYPE) ?: ""
    }

    @JvmStatic
    fun setRomType(romType: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            ROMTYPE, romType, true)
    }


    @JvmStatic
    fun getNetwork(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            NETWORK) ?: ""
    }

    @JvmStatic
    fun setNetwork(network: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            NETWORK, network, true)
    }



    @JvmStatic
    fun getClientIdentifier(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            CLIENTIDENTIFIER) ?: ""
    }

    @JvmStatic
    fun setClientIdentifier(ClientIdentifier: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            CLIENTIDENTIFIER, ClientIdentifier, true)
    }

    @JvmStatic
    fun getScreenType(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            SCREENTYPE) ?: ""
    }

    @JvmStatic
    fun setScreenType(screenType: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            SCREENTYPE, screenType, true)
    }


    @JvmStatic
    fun getPowerTurnType(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(POWERONOFFTYPE,-1)
    }

    @JvmStatic
    fun setPowerTurnType(screenType: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(POWERONOFFTYPE, screenType, true)
    }


    @JvmStatic
    fun getOrgId(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
            ORGANIZATION) ?: 0
    }

    @JvmStatic
    fun setOrgId(orgId: Int) {
        if(orgId < 0){
            return
        }
        SPUtils.getInstance(PREFERENCE_NAME).put(
            ORGANIZATION, orgId, true)
    }




    @JvmStatic
    fun getDeviceStatus(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            DEVICESTATUS) ?: ""
    }

    @JvmStatic
    fun setDeviceStatus(orgId: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            DEVICESTATUS, orgId, true)
    }

    @JvmStatic
    fun getPlanId(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            PLANID) ?: ""
    }

    @JvmStatic
    fun setPlanId(PlanId: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            PLANID, PlanId, true)
    }

    @JvmStatic
    fun setAppVersion(appVersion: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(APPVERSION, appVersion, true)
    }

    @JvmStatic
    fun getAppVersion(): String{
        return SPUtils.getInstance(PREFERENCE_NAME).getString(APPVERSION) ?: ""
    }

    @JvmStatic
    fun getIp(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            IPADRESS) ?: ""
    }

    @JvmStatic
    fun setIp(deviceId: String?) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            IPADRESS, deviceId, true)
    }



//    @JvmStatic
//    fun getPowerOffYear(): Int {
//        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
//            POWEROFFYEAR)
//    }
//
//    @JvmStatic
//    fun setPowerOffYear(time: Int) {
//        SPUtils.getInstance(PREFERENCE_NAME).put(
//            POWEROFFYEAR, time, true
//        )
//    }


    @JvmStatic
    fun clearSettingPower() {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWEROFFHOUR, 0, true
        )
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWEROFFMINUTE, 0, true
        )
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWERONHOUR, 0, true
        )
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWERONMINUTE, 0, true
        )
//        SPUtils.getInstance(PREFERENCE_NAME).put(
//            POWERONOFFTYPE, 0, true
//        )
    }

//    @JvmStatic
//    fun getPowerOffMonth(): Int {
//        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
//            POWEROFFMONTH)
//    }
//
//    @JvmStatic
//    fun setPowerOffMonth(time: Int) {
//        SPUtils.getInstance(PREFERENCE_NAME).put(
//            POWEROFFMONTH, time, true
//        )
//    }
//
//
//    @JvmStatic
//    fun getPowerOffDay(): Int {
//        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
//            POWEROFFDAY)
//    }
//
//    @JvmStatic
//    fun setPowerOffDay(time: Int) {
//        SPUtils.getInstance(PREFERENCE_NAME).put(
//            POWEROFFDAY, time, true
//        )
//    }

    @JvmStatic
    fun getPowerOffHour(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
            POWEROFFHOUR)
    }

    @JvmStatic
    fun setPowerOffHour(time: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWEROFFHOUR, time, true
        )
    }

    @JvmStatic
    fun getPowerOffMinute(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
            POWEROFFMINUTE)
    }

    @JvmStatic
    fun setPowerOffMinute(time: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWEROFFMINUTE, time, true
        )
    }

//    @JvmStatic
//    fun getPowerOnYear(): Int {
//        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
//            POWERONYEAR)
//    }
//
//    @JvmStatic
//    fun setPowerOnYear(time: Int) {
//        SPUtils.getInstance(PREFERENCE_NAME).put(
//            POWERONYEAR, time, true
//        )
//    }
//
//    @JvmStatic
//    fun getPowerOnMonth(): Int {
//        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
//            POWERONMONTH)
//    }
//
//    @JvmStatic
//    fun setPowerOnMonth(time: Int) {
//        SPUtils.getInstance(PREFERENCE_NAME).put(
//            POWERONMONTH, time, true
//        )
//    }
//
//
//    @JvmStatic
//    fun getPowerOnDay(): Int {
//        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
//            POWERONDAY)
//    }
//
//    @JvmStatic
//    fun setPowerOnDay(time: Int) {
//        SPUtils.getInstance(PREFERENCE_NAME).put(
//            POWERONDAY, time, true
//        )
//    }

    @JvmStatic
    fun getPowerOnHour(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
            POWERONHOUR)
    }

    @JvmStatic
    fun setPowerOnHour(time: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWERONHOUR, time, true
        )
    }

    @JvmStatic
    fun getPowerOnMinute(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
            POWERONMINUTE)
    }

    @JvmStatic
    fun setPowerOnMinute(time: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            POWERONMINUTE, time, true
        )
    }

    @JvmStatic
    fun getRebootType(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
            REBOOTTYPE)
    }

    @JvmStatic
    fun setRebootType(rebootType: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            REBOOTTYPE, rebootType, true)
    }


    @JvmStatic
    fun getRebootStatus(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(
            REBOOTSTATUS,100)
    }

    @JvmStatic
    fun setRebootStatus(rebootStatus: Int) {
        SPUtils.getInstance(PREFERENCE_NAME).put(
            REBOOTSTATUS, rebootStatus, true)
    }


    @JvmStatic
    fun getMac(): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(
            MACADRESS) ?: ""
    }

    @JvmStatic
    fun setMac(macId: String?) {
        if(!TextUtils.isEmpty(macId)){
            SPUtils.getInstance(PREFERENCE_NAME).put(
                MACADRESS, macId, true)
        }
    }

    @JvmStatic
    fun getAdvertiseList(): String {
        return SPUtils.getInstance(PREFERENCE_LIST).getString(
            ADVERTISELIST) ?: ""
    }

    @JvmStatic
    fun setAdvertiseList(list: String?) {
        if(!TextUtils.isEmpty(list)){
            SPUtils.getInstance(PREFERENCE_LIST).put(
                ADVERTISELIST, list, true)
        }
    }


    @JvmStatic
    fun getScreenSaver(): String {
        return SPUtils.getInstance(SCREENSAVER_LIST).getString(
            SCREENSAVER) ?: ""
    }

    @JvmStatic
    fun setScreenSaver(list: String?) {
        if(!TextUtils.isEmpty(list)){
            SPUtils.getInstance(SCREENSAVER_LIST).put(
                SCREENSAVER, list, true)
        }
    }

    @JvmStatic
    fun clearAdvertiseList() {
        SPUtils.getInstance(PREFERENCE_LIST).clear(true)
    }

    @JvmStatic
    fun setValue(key: String, value: String?) {
        if (value == null) return
        SPUtils.getInstance(PREFERENCE_NAME).put(key, value)
    }

    @JvmStatic
    fun setOrientation(value: Int?) {
        if (value == null) return
        SPUtils.getInstance(PREFERENCE_NAME).put(Orientation, value)
    }

    @JvmStatic
    fun getOrientation(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(Orientation)
    }

    @JvmStatic
    fun setEnv(value: Int?) {
        if (value == null) return
        SPUtils.getInstance(PREFERENCE_NAME).put(INTENTENV, value)
    }

    @JvmStatic
    fun getEnv(): Int {
        return SPUtils.getInstance(PREFERENCE_NAME).getInt(INTENTENV)
    }

    @JvmStatic
    fun getString(key: String): String {
        return SPUtils.getInstance(PREFERENCE_NAME).getString(key)
    }






    @JvmStatic
    fun clear() {
        SPUtils.getInstance(PREFERENCE_NAME).clear(true)
    }

}